package com.dragonsky.shop.user.sentinel.handler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.dragonsky.shop.common.utils.AjaxResult;
import com.dragonsky.shop.user.domain.vo.StarListVo;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserServiceSentinelHandler {

    /**
     * 限流后续操作方法
     */
    public static AjaxResult<List<StarListVo>> getStarListBlockHandler(BlockException ex) {
        //打印异常
        ex.printStackTrace();

        return AjaxResult.failed("[明星列表]资源访问被限流");
    }

    /**
     * 限流后续操作方法
     */
    public static AjaxResult<List<StarListVo>> getStarListFallbackHandler(Throwable throwable) {
        return AjaxResult.failed("[明星列表]触发熔断，服务不可用");
    }

}
